<!DOCTYPE html>
<html>
<head>
    <!--<link rel="stylesheet" href="./skin01/home_new_yh01.css">
    <link rel="stylesheet" href="./css/home_new_index_reform6.css">-->
</head>

<body>
    <!--mescroll-->
    <div class="tuijian " id="mescroll-tuijian">

            <!-- 推广图 -->
            <div class="extension-banner">
                <!--<img src="/common/img/banner_mall_LCZX.png" alt="">-->
            </div>
        <!--今日关注-->
        <div class="home_new-list jrgz">
            <div class="tztui-list-title jr-title pad15">
                <div class="btm-line">
                    <span class="title">今日关注</span>
                    <span class="title-font1">
						今日机会提醒
					</span>
                    <span class="more">
						<!--更多--><i class="right-arrow"></i>
					</span>
                </div>
            </div>
            <div class="home_new-list-content jrgz-box">
                <div class="swiper-container-jrgz">
                    <div class="swiper-wrapper">
                        <div class="swiper-slide" style="width: 2.864rem; margin-right: 0.11rem;">
                            <div class="box-item">
                                <div class="box-title">
                                    <!--<span class="title-left">01 <img src="./images/jrgz.png" alt="jrgz"></span>-->
                                    <span class="title-mid chunk-default">默认模块</span>
                                    <span class="title-right chunk-default">00:00</span>
                                </div>
                                <div class="box-content1">
                                    <div class="content-top">
                                        <div class="chunk-default">默认介绍内容 默认介绍内容 默认介绍内容 默认介绍内容</div>
                                    </div>
                                    <p class="content-bottom clear">
                                        <span class="left chunk-default">默认股票 --</span>
                                        <span class="right chunk-default">默认股票 --</span>
                                    </p>
                                </div>
                            </div>
                        </div>
                        <div class="swiper-slide" style="width: 2.864rem; margin-right: 0.11rem;">
                            <div class="box-item">
                                <div class="box-title">
                                    <!--<span class="title-left">02 <img src="./images/jrgz.png" alt="jrgz"></span>-->
                                    <span class="title-mid chunk-default">默认模块</span>
                                    <span class="title-right chunk-default">00:00</span>
                                </div>
                                <div class="box-content1">
                                    <div class="content-top">
                                        <div class="chunk-default">默认介绍内容 默认介绍内容 默认介绍内容 默认介绍内容</div>
                                    </div>
                                    <p class="content-bottom clear">
                                        <span class="left chunk-default">默认股票 --</span>
                                        <span class="right chunk-default">默认股票 --</span>
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    
        <!--今日风口-->
        <div class="home_new-list jrfk">
            <div class="tztui-list-title jr-title  pad15">
                <div class="btm-line">
                    <span class="title">今日风口</span>
                    <span class="title-font1">
						实时大涨解读
					</span>
                    <span class="more">
						<!--更多--><i class="right-arrow"></i>
					</span>
                </div>
            </div>
            <div class="home_new-list-content jrfk-box">
                <div class="swiper-container-jrfk">
                    <div class="swiper-wrapper">
                        <div class="swiper-slide" style="width: 1.523rem; margin-right: 0.11rem;">
                            <div class="box-item box-item1">
                                <div class="box-title">
                                    <p class="title f6f8"><!--ST中南--></p>
                                    <p class="value f6f8"><!--+23.18%--></p>
                                </div >
                                <div class="box-content">
                                    <p class="content-top f6f8"><!--低价,此前连续6日跌停,主营影视文化和金属制造业务--></p>
                                    <p class="content-bottom f6f8">
                                        <span class="left"><!--新晨科技--></span>
                                        <span class="right"><!--+10.12%--></span>
                                    </p>
                                </div >
                            </div>
                        </div>
                        <div class="swiper-slide" style="width: 1.523rem; margin-right: 0.11rem;">
                            <div class="box-item box-item2">
                                <div class="box-title">
                                    <p class="title f6f8"><!--区块链--></p>
                                    <p class="value f6f8"><!--+48.78%--></p>
                                </div >
                                <div class="box-content">
                                    <p class="content-top f6f8"><!--低价,此前连续6日跌停,主营影视文化和金属制造业务--></p>
                                    <p class="content-bottom f6f8">
                                        <span class="left"><!--新晨科技--></span>
                                        <span class="right"><!--+10.12%--></span>
                                    </p>
                                </div >
                            </div>
                        </div>
                        <div class="swiper-slide" style="width: 1.523rem; margin-right: 0.11rem;">
                            <div class="box-item  box-item2">
                                <div class="box-title">
                                    <p class="title f6f8"><!--ST中南--></p>
                                    <p class="value f6f8"><!--+23.18%--></p>
                                </div >
                                <div class="box-content">
                                    <p class="content-top f6f8"><!--低价,此前连续6日跌停,主营影视文化和金属制造业务--></p>
                                    <p class="content-bottom f6f8">
                                        <span class="left"><!--新晨科技--></span>
                                        <span class="right"><!--+10.12%--></span>
                                    </p>
                                </div >
                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div>
        <!-- 要闻前三条 -->
        <div class="yaowen-list yaowen-list-three"></div>

        <!-- 投顾观点两条 -->
<!--        <div class="tougu-group tggd"></div>-->
        <!-- 视频列表一条 -->
<!--        <div class="video-list"></div>-->
        <!-- 要闻前三条之后的数据 -->
        <div class="yaowen-list yaowen-list-other"></div>
    </div>

</body>
<script src="/home_new/js/crypto-js.js"></script>
<script src="/home_new/js/info.js"></script>
<script>
    Date.prototype.format = function(fmt) {
        var o = {
            "M+" : this.getMonth()+1,                 //月份
            "d+" : this.getDate(),                    //日
            "h+" : this.getHours(),                   //小时
            "m+" : this.getMinutes(),                 //分
            "s+" : this.getSeconds(),                 //秒
            "q+" : Math.floor((this.getMonth()+3)/3), //季度
            "S"  : this.getMilliseconds()             //毫秒
        };
        if(/(y+)/.test(fmt)) {
            fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
        }
        for(var k in o) {
            if(new RegExp("("+ k +")").test(fmt)){
                fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
            }
        }
        return fmt;
    };

    var readId = [];
    oVal.ywPageNum = 1;
    oVal.loadYWFlag = true;
    oVal.infoOffset = "0";//取接口返回的字段

    tuijianInit();
    function tuijianInit() {
        getJRGZ();//今日关注
        getJRFK();//今日风口
        getYaoWenInfo();//要闻三条
        getTGY();//推广图
        //getTGGD();//投顾两条
        //getSPKC();//视频课程一条
        //mescroll.endSuccess();
    }

    //今日关注
    function getJRGZ() {
        queryhome_newFocusOnToday().then(function(res, i) {
            if(res.data.length) {
                $('.jrgz').show();
                var itemHtml = '<div class="swiper-container-jrgz">\n' +
                        '\t\t\t\t\t\t<div class="swiper-wrapper">';
                var codeList = [];
                res.data.slice(0,3).forEach(function(item, i) {
                    var itemLocation =  ['今日关注位置一','今日关注位置二','今日关注位置三'];
                    var paiming = '0' + (i+1);
                    var gphtml = '';
                    var list = item.faucet.slice(0,2);
                    codeList = codeList.concat(list);
                    list.forEach(function(stockCode) {
                        gphtml += '<span class="cls-stock-info-jrgz" data-id="'+stockCode+'" style="display:none"><i class="code" ></i><i class="range"></i></span>'
                    });
                    itemHtml +='<div class="swiper-slide" style="width: 2.864rem; margin-right: 0.11rem;">\n' +
                            '\t\t\t\t\t\t\t<div class="box-item" data-index="' + i +'" data-location="'+ itemLocation[i] +'" plate-id="'+item.plateId+'" data-id="'+item.subjectId+'">\n' +
                            '\t\t\t\t\t\t\t\t<div class="box-title">\n' +
                            '\t\t\t\t\t\t\t\t\t<span class="title-left">'+paiming+'<img src="./images/jrgz.png" alt="jrgz"></span>\n' +
                            '\t\t\t\t\t\t\t\t\t<span class="title-mid">'+item.subjectName+'</span>\n' +
                            '\t\t\t\t\t\t\t\t\t<span class="title-right"></span>\n' +
                            '\t\t\t\t\t\t\t\t</div>\n' +
                            '\t\t\t\t\t\t\t\t<div class="box-content1">\n' +
                            '\t\t\t\t\t\t\t\t\t<p class="content-top">'+item.interpret+'</p>\n' +
                            '\t\t\t\t\t\t\t\t\t<p class="content-bottom clear">'+gphtml+'</p>\n' +
                            '\t\t\t\t\t\t\t\t</div>\n' +
                            '\t\t\t\t\t\t\t</div>\n' +
                            '\t\t\t\t\t\t</div>';
                });
                timehtml=null;
                var showTouchMore = !!(res.data.length>=3);
                if(showTouchMore) {
                    itemHtml+='<div class="sfckgd-p"><div class="sfckgd">释放查看更多 <img src="./images/sf_right.png" alt=""></div></div>';
                }
                itemHtml+='</div></div>';
                $('.jrgz .jrgz-box').html(itemHtml);
                renderStockInfo(codeList, 'cls-stock-info-jrgz');
                    //重置dom点击事件
                    JRGZEvent();
                oVal.swiper_jrgz = new Swiper('.swiper-container-jrgz', {
                    slidesPerView: 'auto',
                    spaceBetween: 10,
                    slidesOffsetAfter : 5,
                    onTouchEnd: showTouchMore ? function(swiper,event){
                        //在最后一页继续拖动则释放跳转
                        //console.log("跳转事件执行",swiper.translate,event);
                        var _width=$(".jrgz-box .swiper-slide").width()*2;
                        if((swiper.translate+_width)<-40){
                            //console.log("跳转")
                            var oSend = {url:'/zx2/zx_chance.html'};
                            T.fn.action10061(oSend);
                            /*onJsOverrideUrlLoading("http://action:11004?type=jh");*/
                        }
                    } : undefined,
                });
            }else {
                $('.jrgz').hide();
            }
        }).catch(function() {
            $('.jrgz').hide();
        })

    }
    function JRGZEvent(){
        //跳转机会模块
        $('.jrgz .more').off().on('click', function() {
            //今日关注事件埋点
            track.sensors.track('second_list_click', {
                'bottomtabbar_name': '探索',
                'toptabbar_name': '首页',
                'first_list_name': '今日关注',
                'second_list_type': '列表',
                'second_list_name': '今日关注'
            });

            // 首页栏位点击-今日关注-更多
            pageSensors.reportClick('mainPageColumnClick', {
                column_type: '今日关注',
                column_name: '今日关注-更多',
                column_no: ''
            })

            var oSend = {url:'/zx2/zx_chance.html?'};
            T.fn.action10061(oSend);
            /*onJsOverrideUrlLoading("http://action:11004?type=jh");*/
        });
        $('.jrgz .box-item').off().on('click', function() {
            //今日关注列表事件埋点
            var location = $(this).attr('data-location');
            var index = $(this).attr('data-index');
            if (location) {
                track.sensors.track('second_list_click', {
                    'bottomtabbar_name': '探索',
                    'toptabbar_name': '首页',
                    'first_list_name': '今日关注',
                    'second_list_type': '列表位置',
                    'second_list_name': location
                });
            }

            // 首页栏位点击-栏目-更多
            pageSensors.reportClick('mainPageColumnClick', {
                column_type: '今日关注',
                column_name: $(this).find('.content-top').text(),
                column_no: index
            })

            var sId = $(this).attr('plate-id');
            var obj = {
                'url':'/hq/zt_xq.html?id=' + sId + ''
            };
            var oSend = {url:obj.url};
            TZT.fn.action10061(oSend);
        });
        //跳转个股行情页
        $('.jrgz .content-bottom span').off().on('click', function(event) {
            T.stopBubble();
            var stockcode=$(this).find(".code").attr('data-id');
            var stocktype=$(this).find(".code").attr('data-market');
            onJsOverrideUrlLoading("http://action:12051/?stockcode=" + stockcode+ "&&stocktype=" + stocktype);
        })

    }

    //今日风口
    function getJRFK() {
        queryhome_newTodayRise(new Date().format('yyyy-MM-dd'), true).then(function(res) {
            if(!res.data.length) {
                $('.jrfk').hide();
                return;
            }
            $('.jrfk').show();
            var itemHtml = '<div class="swiper-container-jrfk">\n' +
                        '\t\t\t\t\t\t<div class="swiper-wrapper">';
            var itemLocation = ['今日风口位置一', '今日风口位置二', '今日风口位置三'];
            var codeList = [];
            res.data.slice(0,3).forEach(function(item, i) {
                var gphtml = '';
                if(item.stockPool.length) {
                    var stockCode = item.stockPool[0];
                    codeList.push(stockCode);
                    gphtml='<span class="cls-stock-info-jrfk" data-id="'+stockCode+'" style="display:none"><span class="left code " data-id="'+stockCode+'"></span><span class="right range"></span></span>';
                }
                itemHtml +='<div class="swiper-slide" style="width: 1.523rem; margin-right: 0.11rem;">\n' +
                            '\t\t\t\t\t\t\t<div class="box-item box-item1" data-location="'+itemLocation[i]+'">\n' +
                            '\t\t\t\t\t\t\t\t<div class="box-title">\n' +
                            '\t\t\t\t\t\t\t\t\t<p class="title" data-id="'+item.plateId+'">'+item.plateName+'</p>\n' +
                            '\t\t\t\t\t\t\t\t\t<p class="value"></p>\n' +
                            '\t\t\t\t\t\t\t\t</div >\n' +
                            '\t\t\t\t\t\t\t\t<div class="box-content">\n' +
                            '\t\t\t\t\t\t\t\t\t<p class="content-top">'+item.remark+'</p>\n' +
                            '\t\t\t\t\t\t\t\t\t<p class="content-bottom">'+gphtml+'</p>\n' +
                            '\t\t\t\t\t\t\t\t</div >\n' +
                            '\t\t\t\t\t\t\t</div>\n' +
                            '\t\t\t\t\t\t</div>';
            });
            var showTouchMore = !!(res.data.length>=3);
            if(showTouchMore) {
                itemHtml+='<div class="sfckgd-p"><div class="sfckgd">释放查看更多 <img src="./images/sf_right.png" alt=""></div></div>';
            }
            itemHtml+='</div></div>';
            $('.jrfk .jrfk-box').html(itemHtml);
            renderStockInfo(codeList, 'cls-stock-info-jrfk');
            JRFKEvent();
            var swiper_jrfk = new Swiper('.swiper-container-jrfk', {
                slidesPerView: 'auto',
                spaceBetween: 10,
                slidesOffsetAfter : 5,
                onTouchEnd: showTouchMore ? function(swiper,event){
                    //在最后一页继续拖动则释放跳转
                    var _width=$(".jrfk .swiper-slide").width();
                    if((swiper.translate+_width)<-50){
                        var oSend = {url:'/hq/jrfk.html'};
                        T.fn.action10061(oSend);
                    }
                } : undefined,
            });
        }).catch(function() {
            $('.jrfk').hide();
        });
    }
    function JRFKEvent(){
        //跳转今日风口模块
        $('.jrfk .more').off().on('click', function() {
            //今日风口事件埋点
            track.sensors.track('second_list_click',{
                'bottomtabbar_name': '探索',
                'toptabbar_name': '首页',
                'first_list_name': '今日风口',
                'second_list_type': '列表',
                'second_list_name': '今日风口'
            });

            // 首页栏位点击-今日风口-栏目
            pageSensors.reportClick('mainPageColumnClick', {
                column_type: '今日风口',
                column_name: '今日风口-更多',
                column_no: ''
            })

            var oSend = {url:'/hq/jrfk.html'};
            T.fn.action10061(oSend);
        });
        //跳转对应主题
        $('.jrfk .box-item').off().on('click', function() {
            //今日风口列表事件埋点
            var location = $(this).attr('data-location');
            var index = $(this).attr('data-index');
            track.sensors.track('second_list_click',{
                'bottomtabbar_name': '探索',
                'toptabbar_name': '首页',
                'first_list_name': '今日风口',
                'second_list_type': '列表位置',
                'second_list_name': location
            });

            // 首页栏位点击-今日风口-栏目
            pageSensors.reportClick('mainPageColumnClick', {
                column_type: '今日风口',
                column_name: $(this).find('.content-top').text(),
                column_no: index
            })

            var sId = $(this).find(".title").attr('data-id');
            var obj = {
                'url':'/hq/zt_xq.html?id=' + sId + ''
            };
            var oSend = {url:obj.url};
            TZT.fn.action10061(oSend);
        })
    }
    // 主题详情
    function getZTXQ(id,dom1,dom2) {
        var oSendData = {
            action:'50052',
            channel_num:'1',//渠道识别，备注：可以在配置文件里面改，要和华福约定，暂时先用1
            menu_id:'005',
            ReqLinkType: '2',
            nPage: 1,
            maxcount: 10,
            plate_id:id,
        };
        $.getData({oSendData:oSendData,isload:false,fnSuccess:function(data){
                //console.log("主题详情：",data)
                if(data&&data.GRID0.length>=1) {
                    var oData=data.GRID0[0].split('|');
                    var codeArr=[];
                    for(var i=0;i<data.GRID0.length;i++){
                        var oData1=data.GRID0[i].split('|');
                        codeArr.push(oData1[data.STOCK_CODE]);
                        if(i==data.GRID0.length-1){
                            getStock1(codeArr,dom2);
                        }
                    }

                    dom1.html(oData[data.PLATE_DESC]);

                }else{
                    //暂无数据
                }
            },oConfig:function(error){
                console.log("主题详情接口报错：",error);
            }});
    }
    /*今日风口获取股票涨跌幅*/
    function getStock1(stockcode,oDom) {
        if(stockcode){
            var oSendData = {
                Action: 60,
                grid: stockcode.join(','),
                NewMarketNo: 1,
                ReqlinkType: 2,
                maxCount: 100,
                AccountIndex: 0,
                StockIndex: 1,
            };
            $.getData({
                oSendData: oSendData,
                copyIsArray: false,
                isload: false,
                fnSuccess: function(data) {
                    //console.log("股票：",data,data.GRID0[1].split("|")[data.UPDOWNPINDEX]);return;
                    var _zdf=data.GRID0[1].split("|")[data.UPDOWNPINDEX],zdClass="";
                    if(Number(_zdf.replace("%",""))>0){//判断股票是涨幅还是跌幅
                        zdClass="zf";
                        _zdf="+"+_zdf;
                    }else{
                        zdClass="df"
                    }
                    //console.log(oDom,oDom.parent());
                    oDom.parent().addClass(zdClass);
                    oDom.html(_zdf);
                    oDom.parent().find(".code").attr("date-id",data.GRID0[1].split("|")[data.STOCKCODEINDEX]);
                    var _name=data.GRID0[1].split("|")[data.STOCKNAMEINDEX]
                    if(_name.indexOf(".")>-1){
                        _name=_name.split(".")[1]
                    }
                    oDom.parent().find(".code").html(_name);
                }
            });
        }else{
            return null;
        }

    };

    /*处理格林尼治时间*/
    function setDateTime(fnTime) {
        var x = fnTime; // 取得时间"2017-07-08 13:00:00"
        if(!T.judge('ISIOS')){
            x=fnTime;
        }else{//处理下，ios转换有问题
            x=fnTime.replace(/-/g,'/');
        }
        var time = new Date(x);
        var timeNum = 8;//小时数
        time.setHours(time.getHours() + timeNum);
        return time;
    }
    
    /*今日关注获取股票涨跌幅*/
    function getStock2(stockcode) {
        if(stockcode){
            var oSendData = {
                Action: 60,
                grid: stockcode.join(','),
                NewMarketNo: 1,
                ReqlinkType: 0,
                maxCount: 100,
                AccountIndex: 0,
                StockIndex: 1,
            };
            $.getData({
                oSendData: oSendData,
                copyIsArray: false,
                isload: false,
                fnSuccess: function(data) {
                    for(var i=1;i<data.GRID0.length;i++){
                        var oData=data.GRID0[i].split("|");
                        var _zdf=oData[data.UPDOWNPINDEX],zdClass="";
                        if(Number(_zdf.replace("%",""))>0){//判断股票是涨幅还是跌幅
                            zdClass="zf";
                            _zdf="+"+_zdf;
                        }else if(Number(_zdf.replace("%",""))<0){
                            zdClass="df"
                        }
                        $(".jrgz .code").each(function(){
                            if($(this).attr("data-id")==oData[data.STOCKCODEINDEX]){
                                $(this).next().html(_zdf);
                                $(this).parent().addClass(zdClass)
                            }
                        })
                    }
                },
                oConfig:function (error) {
                    console.log(error)
                }
            });
        }else{
            return null;
        }

    }

    /*要闻三条*/
    function getYaoWenInfo() {
        /*if(oVal.configData.THS_MZ_KEY || oVal.configData.THS_MZ_KEY == "0"){
            //旧版资讯推荐
            getOldYaoWenInfo()
        }else{

        }*/
        // console.log(oVal.ywPageNum,oVal.ywPageNum);
        var oSendData = {
            action: '31020',
            param:JSON.stringify({
                "accessKey":"e6ce431bd537718a",
                "infoOffset":oVal.infoOffset,//当前已遍历查询的资讯页数，默认为 0
                "page":oVal.ywPageNum - 1,
            }),
            ReqLinkType: '2'
        };
        $.getData({
            oSendData: oSendData,
            copyIsArray: false,
            isload: false,
            fnSuccess: function (data) {
                // console.log("推荐-要闻",data,JSON.parse(data.BINDATA));
                var sHtml = '',sHtmlOther = '';
                if (data.BINDATA) {
                    var _result = JSON.parse(data.BINDATA).data;
                    oVal.infoOffset = JSON.parse(data.BINDATA).infoOffset;
                    if(_result.length > 0){
                        oVal.ywNextPage = JSON.parse(data.BINDATA).hasNext;
                        for (var i = 0; i < _result.length; i++) {
                            var obj = {};
                            obj.id = _result[i].itemId;//id
                            obj.ctime = _result[i].time;//时间，日期
                            obj.imgUrl = _result[i].imgUrl;//图片
                            obj.source = _result[i].source;//来源
                            obj.title = _result[i].title;//标题
                            obj.copyright = _result[i].copyright;//有无版权
                            obj.url = _result[i].url;//无版权时的三方地址

                            if(i < 3){
                                if(obj.copyright && obj.copyright == "1"){
                                    sHtml += loadDOM_TT(obj);
                                }
                            }else{
                                if(obj.copyright && obj.copyright == "1"){
                                    sHtmlOther += loadDOM_TT(obj);
                                }
                            }
                        }
                    }
                }
                $('.yaowen-list-three').html(sHtml);
                $('.yaowen-list-other').html(sHtmlOther);
                pageUrl();
            },
            oConfig:function () {

            }
        });
    }
    function loadDOM_TT(data){
        var readClass='';
        /*if(readId.toString().indexOf(data.id) > -1){
            readClass='zx-read-name';
        }*/
        var newDate = dateStr(formatDate(data.ctime));
        //var newDate = formatDateHM(data.ctime);
        var sHtml = '<li class="zx-list" data-copyright="' + data.copyright + '" data-url="' + data.url + '" data-id="' + data.id + '"  data-time="' + formatDate(data.ctime) + '"  data-title="' + data.title + '"  data-source="' + data.source + '">'
            /*+'<img  src="'+ data.imgUrl +'" onload=this.nextSibling.style.display="none"; class="img">'
            +'<img  src="./img/moren.png" class="none">'*/
            + '<p class="zx-name '+ readClass + '">' + data.title + '</p><p class="zx-foot">'
            + '<span class="zx-date">' + newDate + '</span>'
            + '<span class="zx-media" style="float: left;padding-right: 0.1rem;">' + data.source + '</span></p>'
            + '</li>';
        return sHtml;
    }
    function formatDate(timestamp) {
        var date = new Date(timestamp*1000);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
        var Y = date.getFullYear(),
            M = (date.getMonth()+1 < 10 ? (date.getMonth()+1) : date.getMonth()+1),
            D = date.getDate(),
            h = date.getHours(),
            m = date.getMinutes(),
            s = date.getSeconds();
        M = M < 10 ? "0"+ M : M;
        D = D < 10 ? "0"+ D : D;
        h = h < 10 ? "0"+ h : h;
        m = m < 10 ? "0"+ m : m;
        s = s < 10 ? "0"+ s : s;
        return Y+"-"+M+"-"+D+" "+h+":"+m+":"+s;
    }
    function formatDateHM(timestamp) {
        var date = new Date(timestamp*1000);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
        var Y = date.getFullYear(),
            M = (date.getMonth()+1 < 10 ? (date.getMonth()+1) : date.getMonth()+1),
            D = date.getDate(),
            h = date.getHours(),
            m = date.getMinutes(),
            s = date.getSeconds();
        M = M < 10 ? "0"+ M : M;
        D = D < 10 ? "0"+ D : D;
        h = h < 10 ? "0"+ h : h;
        m = m < 10 ? "0"+ m : m;
        s = s < 10 ? "0"+ s : s;
        return h+":"+m;
    }

    //旧版资讯推荐
    function getOldYaoWenInfo(){  //上拉加载的回调
        var oSendData = {
            'action': '46118',//东财转开利，接口做调整
            'nPage': "1",
            'maxcount': "20",
            'menu_id': '20001',/*20024,20023,20025,20017*/
            ReqLinkType: '2'
        };
        $.getData({
            oSendData: oSendData,
            copyIsArray: false,
            isload: false,
            fnSuccess: function (data) {
                var aGrid = data.GRID0;
                var sHtml = '',sHtmlOther = '';
                if (aGrid) {
                    for (var i = 0; i < aGrid.length; i++) {
                        var _result = aGrid[i].split('|');
                        var obj = {};
                        obj.id = _result[data['IDINDEX']];//id
                        obj.ctime = _result[data['DATESINDEX']];//时间，日期
                        obj.imgUrl = _result[data['PICURLINDEX']];//图片
                        obj.source = _result[data['MEDIAINDEX']];//来源
                        obj.title = _result[data['INFOTITLEINDEX']];//标题

                        if(i < 3){
                            sHtml += loadDOM_TT_Old(obj);
                        }else{
                            sHtmlOther += loadDOM_TT_Old(obj);
                        }
                    }
                }

                if(aGrid.length >=20){
                    oVal.ywNextPage = true;
                }else{
                    oVal.ywNextPage = false;
                }

                $('.yaowen-list-three').html(sHtml);
                $('.yaowen-list-other').html(sHtmlOther);
                pageUrlOld();
            },
            oConfig:function(){

            }
        });
    }
    function loadDOM_TT_Old(data){
        var readClass='';
        /*if(readId.toString().indexOf(data.id) > -1){
            readClass='zx-read-name';
        }*/
        var newDate = dateStr(data.ctime);
        var sHtml = '<li class="zx-list" data-id="' + data.id + '">'
            /*+'<img  src="'+ data.imgUrl +'" onload=this.nextSibling.style.display="none"; class="img">'
            +'<img  src="./img/moren.png" class="none">'*/
            + '<p class="zx-name '+ readClass + '">' + data.title + '</p><p class="zx-foot">'
            + '<span class="zx-date">' + newDate + '</span>'
            + '<span class="zx-media" style="float: left;padding-right: 0.1rem;">' + data.source + '</span></p>'
            + '</li>';
        return sHtml;
    }
    function pageUrlOld() {
        var action='read.txt';
        $('.zx-list').off().on('click', function(){
            var imgsrc = encodeURIComponent($(this).find("img").attr("src"));
            var sId = $(this).attr('data-id');
            var obj = {
                'url':'/zx2/zx_zxxq.html?id=' + sId + '&&type=tuijian&&imgsrc='+imgsrc
            };
            pageSensors.reportClick('mainPageColumnClick', {
                column_type: '要闻',
                column_name: '要闻点击',
                column_no: $(this).index()
            })

            $(this).find(".zx-name").addClass('zx-read-name');
            if(readId.toString().indexOf(sId) == -1){
                readId.push(sId);
            }
            T.saveFileMesg(readId,action,function(oData){
                T.readFileMesg(action,function(oData){
                    var oSend = {url:obj.url};
                    oSend.secondtype = '98';
                    oSend.secondtext = 'tzt_zx.png';
                    oSend.secondjsfuncname = 'tztPageSecodeFun()';
                    oSend.TitleSkinType = 1;
                    TZT.fn.action10061(oSend);
                })
            });
        });
    }

    function dateStr(date){
        //console.log(date)
        var nowDate = new Date();
        var time=nowDate.getTime();
        var nowyear = nowDate.getFullYear();
        var year = date.substr(0,4);
        var month = Number(date.substr(5,2));
        var day = Number(date.substr(8,2));
        var hour = Number(date.substr(11,2));
        var minute = Number(date.substr(14,2));
        var second = Number(date.substr(17,2));
        var newDate = new Date(year,month-1,day,hour,minute,second).getTime();
        time=parseInt((time-newDate)/1000);
        var s;
        if(time<60*5){//五分钟内
            return '刚刚';
        }else if((time<60*60)&&(time>=60*5)){//超过十分钟少于1小时
            s = Math.floor(time/60);
            return  s+"分钟前";
        }else if((time<60*60*24)&&(time>=60*60)){ //超过1小时少于24小时
            s = Math.floor(time/60/60);
            return  s+"小时前";
        }else if((time<60*60*24*3)&&(time>=60*60*24)){ //超过1天少于3天内
            s = Math.floor(time/60/60/24);
            return s+"天前";
        }else{ //超过3天
            if (year == nowyear) {
                return date.substr(5,5);
            }else{
                return date.split(" ")[0];
            }
        }
    }
    function dateStrTG(date){
        //console.log(date)
        var nowDate = new Date();
        var time=nowDate.getTime();
        var nowyear = nowDate.getFullYear();
        var year = date.substr(0,4);
        var month = Number(date.substr(5,2));
        var day = Number(date.substr(8,2));
        var hour = Number(date.substr(11,2));
        var minute = Number(date.substr(14,2));
        var second = Number(date.substr(17,2));
        var newDate = new Date(year,month-1,day,hour,minute,second).getTime();
        time=parseInt((time-newDate)/1000);
        var s;
        if(time<60*5){//五分钟内
            return '刚刚';
        }else if((time<60*60)&&(time>=60*5)){//超过十分钟少于1小时
            s = Math.floor(time/60);
            return  s+"分钟前";
        }else if((time<60*60*24)&&(time>=60*60)){ //超过1小时少于24小时
            s = Math.floor(time/60/60);
            return  s+"小时前";
        }else if((time<60*60*24*3)&&(time>=60*60*24)){ //超过1天少于3天内
            s = Math.floor(time/60/60/24);
            return s+"天前";
        }else{ //超过3天
            return date
            /*if (year == nowyear) {
                return date.substr(5,5);
            }else{
                return date.split(" ")[0];
            }*/
        }
    }
    function pageUrl(){
        var action='read.txt';
        $('.zx-list').off().on('click', function(){
            var sId = $(this).attr('data-id'),
                time = $(this).attr('data-time'),
                source = $(this).attr('data-source'),
                jumpurl = $(this).attr('data-url'),
                copyright = $(this).attr('data-copyright'),
                title = $(this).attr('data-title');
            var obj = {
                'url':'/zx2/zx_zxxq.html?type=ths&id=' + sId + '&time='+ encodeURIComponent(time) + '&source='+ encodeURIComponent(source)
            };
            var oSend = {url:obj.url};

            pageSensors.reportClick('mainPageColumnClick', {
                column_type: '要闻',
                column_name: '要闻点击',
                column_no: $(this).index()
            })

            // $(this).find(".zx-name").addClass('zx-read-name');
            if(readId.toString().indexOf(sId) == -1){
                readId.push(sId);
            }
            T.saveMapMesg({'THSPAGETITLE': title}, function () {});
            T.saveFileMesg(readId,action,function(oData){
                T.readFileMesg(action,function(oData){
                    if(copyright == "1"){
                        TZT.fn.action10061(oSend);
                    }else{
                        TZT.fn.action10061({url:jumpurl});
                    }
                })
            });
        });
    }

    //推广图
    function getTGY() {
        $.getData({
            oSendData: {
                'action': '41500',
                'type': 'TGJDT',
                'ReqlinkType': '2'
            },
            isload: false,
            fnSuccess: function(oData) {
                // console.log(oData)
                if(oData.GRID0 && oData.GRID0.length > 1){
                    var data_grid=oData.GRID0;
                    data_grid.shift();
                    var sHtml='';
                    for(var i=0;i<1;i++){
                        var data = data_grid[i].split("|"),
                            click_url = data[oData.IMAGE_CLICK_INDEX],
                            img_title = data[oData.IMAGE_TITLE_INDEX],
                            img_url = data[oData.IMAGE_URL_INDEX];
                        if(img_url){
                            sHtml+='<img class="image" src="'+img_url+'" data-title="'+ img_title +'" data-url="'+click_url+'" onerror="$(this).remove();">';
                        }
                    }

                    $(".extension-banner").html(sHtml).show();
                    TGYEvent();
                }else{
                    $(".extension-banner").hide();
                }
            },
            oConfig:function (error) {
                $(".extension-banner").hide();
            }
        })
    }
    function TGYEvent() {
        $(".extension-banner img").off().on("click",function () {
            var url =  $(this).attr('data-url');
            var title =  $(this).attr('data-title');
            if(url){
                pageSensors.reportClick('bannerClick', {
                    banner_id: 0,
                    banner_name: title,
                    jump_url: url
                })
                T.fn.changeURL(url);
                //T.fn.action10061({url:url});
            }
        })
    }

    /*投顾两条*/
    var testIp='';
    function getTGGD() {
        $.getData({
            oSendData:{
                action:'49245',
                ReqlinkType:2,
                funcNo: '1106403',//1106403,1106416
                dataType: "json",
                num_per_page: "2",
                method:'post'
            },
            isload:false,
            fnSuccess:function(data){
                if(data) {
                    if(data.DATA){
                        $('.tougu-group').show();
                        testIp = data.ERRORMESSAGE;
                        var oData = $.parseJSON($.parseJSON(data.DATA));
                        oData = oData[0].data;
                        // console.log(oData);
                        var itemHtml = '';
                        for(var i = 0; i < oData.length; i++) {
                            var face_image_small = oVal.tgJumpId + oData[i].face_image_small,
                                invest_id = oData[i].invest_id,
                                introdution = oData[i].introdution,
                                read_num = oData[i].read_num,
                                title = oData[i].title,
                                view_type = oData[i].view_type,
                                invest_label = oData[i].invest_label,//1=金牌投顾，2=明星投顾，3=投资顾问
                                create_time = oData[i].create_time,
                                is_pay = oData[i].is_pay,//是否付费
                                invest_name = oData[i].invest_name;
                            create_time = dateStrTG(create_time);
                            var className = "";
                            if(invest_label == "1"){
                                invest_label = "金牌投顾";
                                className = "tougu-jp"
                            }else if(invest_label == "2"){
                                invest_label = "明星投顾";
                                className = "tougu-mx"
                            }else if(invest_label == "3"){
                                invest_label = "投资顾问";
                            }else{
                                invest_label = "";
                            }
                            var payHtml = "";
                            if(is_pay == "1"){
                                payHtml = "<em>付费</em>";
                            }
                            itemHtml += '<div class="tougu-list" data-id="'+ invest_id +'">\n' +
                                '                <div class="tougu-head">\n' +
                                '                <span class="head-img">\n' +
                                '                    <img src="'+ face_image_small +'" alt="">\n' +
                                '                </span>\n' +
                                '                    <span class="head-name">'+ invest_name +'</span>\n' +
                                '                    <span class="head-desc '+ className +'"><em>'+ invest_label +'</em></span>\n' +
                                '                </div>\n' +
                                '                <div class="tougu-title">\n' +
                                '                    <span class="title-desc">'+ title + payHtml +'</span>\n' +
                                '                    <span class="title-icon"></span>\n' +
                                '                </div>\n' +
                                '                <div class="tougu-content">'+ introdution +'</div>\n' +
                                '                <div class="tougu-footer">\n' +
                                '                    <span class="footer-read">'+ read_num +'人正在观看</span>\n' +
                                '                    <span class="footer-time">'+ create_time +'</span>\n' +
                                '                </div>\n' +
                                '            </div>'
                        }

                        $(".tougu-group").html(itemHtml);
                        TGGDEvent();
                    }else{
                        $('.tougu-group').hide();
                    }
                }
            },
            oConfig:function(error){
                $('.tougu-group').hide();
            }});
    }
    function TGGDEvent(){
        //跳转观点详情
        $('.tggd .tougu-list').off().on('click',  function() {
            //牛人观点事件埋点
            var location = $(this).attr('data-location');
            track.sensors.track('second_list_click', {
                'bottomtabbar_name': '探索',
                'toptabbar_name': '首页',
                'first_list_name': '牛人观点',
                'second_list_type': '列表位置',
                'second_list_name': location
            });

             // 首页栏位点击-投顾观点
            pageSensors.reportClick('mainPageColumnClick', {
                column_type: '要闻',
                column_name: '要闻点击',
                column_no: $(this).index()
            })

            var id = $(this).data('id');
            //var url = testIp + '/m/ytg/views/loadPage.html?toPagecode=point/detail&view_id=' + id + '&source_id=hzzz';
            var url = testIp + '/m/app/#/?toPagecode=viewDetail&view_id=' + id + '&source_id=hzzz';
            tgFunc(url);
        })
    }
    function tgFunc(url){
        T.readLocalMesg(['jyloginflag','logintype=1','MOBILECODE','usercode'],function(oLocal){
            var MOBILECODE=oLocal.MOBILECODE;
            var USERCODE=oLocal.USERCODE;
            if(MOBILECODE=='' || !MOBILECODE||MOBILECODE=='null'){
                //console.log(url);
                T.fn.action10061({url:url,'tzthiddentitle':'1','tztadjustnever':'1'});
            }else{
                if(oLocal.JYLOGINFLAG <=1){ //未登录
                    var oSend = {
                        action:'5',
                        needToken:'0'
                    }
                    $.getData({oSendData:oSend,isToken:false ,fnSuccess:function(oTime){
                            var serverTime = oTime.TIME;
                            var oSend = {
                                action:'46200',
                                ReqlinkType:2,
                            };
                            $.getData({oSendData:oSend, fnSuccess:function(oData){
                                    var PUBLICK_KEY = oData.TG,MD5_KEY = oData.HSSTRING;
                                    var str = JSON.stringify({mobile:MOBILECODE,from:'sidi',time:serverTime});
                                    //处理rsa和md5key
                                    var senddata = encryptRsaTg(PUBLICK_KEY,MD5_KEY,str);
                                    var oUrl = url+ '&data='+ encodeURIComponent(senddata.data);
                                    //console.log(oUrl);
                                    //console.log(senddata.data);
                                    if (T.appversion.andriod()) {
                                        T.fn.action10061({url:url+'&data=' +encodeURIComponent(encodeURIComponent(senddata.data)),'tzthiddentitle':'1','tztadjustnever':'1'});
                                    } else {
                                        T.fn.action10061({url:oUrl,'tzthiddentitle':'1','tztadjustnever':'1'});
                                    }
                                }});
                        }});
                }else{
                    var oSend = {
                        action:'5',
                        needToken:'0'
                    }
                    $.getData({oSendData:oSend,isToken:false ,fnSuccess:function(oTime){
                            var serverTime = oTime.TIME;
                            /*if(oLocal.JYLOGINFLAG <=1){ //未登录
                                T.fn.action10061({url:url,'tzthiddentitle':'1','tztadjustnever':'1'});
                            }else{*/
                            var oSendData = {
                                action:6771,
                                ReqlinkType:'1'
                            }
                            $.getData({oSendData:oSendData, fnSuccess:function(reg){
                                    var SERVTICKET_ID = reg.SERVTICKET_ID;
                                    var oSend = {
                                        action:'46200',
                                        ReqlinkType:2,
                                    };
                                    $.getData({oSendData:oSend, fnSuccess:function(oData){
                                            var PUBLICK_KEY = oData.TG,MD5_KEY = oData.HSSTRING;
                                            var str = JSON.stringify({token:SERVTICKET_ID,mobile:MOBILECODE,client_id:USERCODE,from:'sidi',time:serverTime});
                                            //处理rsa和md5key
                                            var senddata = encryptRsaTg(PUBLICK_KEY,MD5_KEY,str);
                                            var oUrl = url+ '&data='+ senddata.data;
                                            if (T.appversion.andriod()) {
                                                T.fn.action10061({url:url+'&data=' +encodeURIComponent(encodeURIComponent(senddata.data)),'tzthiddentitle':'1','tztadjustnever':'1'});
                                            } else {
                                                T.fn.action10061({url:oUrl,'tzthiddentitle':'1','tztadjustnever':'1'});
                                            }
                                        }});
                                }});
                            /*}*/
                        }});
                }
            }
        });
    }

    /*视频课程一条*/
    function getSPKC(){
        $.getData({
            oSendData:{
                action:'49245',
                ReqlinkType:2,
                funcNo: '1106391',
                dataType: "json",
                method:'post'
            },
            isload:false,
            fnSuccess:function(data){
                if(data) {
                    if(data.DATA){
                        $('.video-list').show();
                        testIp = data.ERRORMESSAGE;
                        var oData = $.parseJSON($.parseJSON(data.DATA));
                        oData = oData[0].data
                        // console.log("视频课程：",oData);
                        var ln = data.length,itemHtml = '';
                        for(var i = 0; i < 1; i++) {
                            var curriculum_image = oVal.tgJumpId + oData[i].curriculum_image,
                                curriculum_id = oData[i].curriculum_id;
                            itemHtml += '<img data-id="'+ curriculum_id +'" src="'+ curriculum_image +'" alt="">'
                        }

                        $(".video-list").html(itemHtml);

                        $(".video-list img").off().on("click",function () {
                            if(oVal.configData){
                                //课程详情字段TGCLASSDETAILLINK
                                if(oVal.configData.TGCLASSDETAILLINK){
                                    var oUrl = oVal.configData.TGCLASSDETAILLINK.replace("{id}",$(this).attr("data-id"));
                                     // 首页栏位点击-牛人观点
                                    pageSensors.reportClick('mainPageColumnClick', {
                                        column_type: '要闻',
                                        column_name: '视频点击',
                                        column_no: 0
                                    });

                                    T.fn.action10061({url:oUrl,'tzthiddentitle':'1','tztadjustnever':'1'});
                                }
                            }
                        })
                    }else{
                        $('.video-list').hide();
                    }
                }
            },
            oConfig:function(error){
                $('.video-list').hide();
            }});
    }

    /*要闻其他数据*/
    function getYaoWenOtherInfo() {
        var oSendData = {
            action: '31020',
            param:JSON.stringify({
                "accessKey":"e6ce431bd537718a",
                "infoOffset":oVal.infoOffset,//当前已遍历查询的资讯页数，默认为 0
                "page":oVal.ywPageNum - 1,
            }),
            ReqLinkType: '2'
        };
        $.getData({
            oSendData: oSendData,
            copyIsArray: false,
            isload: false,
            fnSuccess: function (data) {
                // console.log(data,JSON.parse(data.BINDATA));
                var sHtml = '';
                if (data.BINDATA) {
                    var _result = JSON.parse(data.BINDATA).data;
                    oVal.infoOffset = JSON.parse(data.BINDATA).infoOffset;
                    if(_result.length > 0){
                        oVal.ywNextPage = JSON.parse(data.BINDATA).hasNext;
                        for (var i = 0; i < _result.length; i++) {
                            var obj = {};
                            obj.id = _result[i].itemId;//id
                            obj.ctime = _result[i].time;//时间，日期
                            obj.imgUrl = _result[i].imgUrl;//图片
                            obj.source = _result[i].source;//来源
                            obj.title = _result[i].title;//标题
                            obj.copyright = _result[i].copyright;//有无版权
                            obj.url = _result[i].url;//无版权时的三方地址
                            if(obj.copyright && obj.copyright == "1"){
                                sHtml += loadDOM_TT(obj);
                            }
                        }
                        $('.yaowen-list-other').append(sHtml);
                        pageUrl();
                        oVal.loadYWFlag = true;
                    }
                }

            },
            oConfig:function(){

            }
        });
    }

    //旧版资讯推荐
    function getOldYaoWenOtherInfo() {
        var oSendData = {
            'action': '46118',//东财转开利，接口做调整
            'nPage': oVal.ywPageNum,
            'maxcount': "20",
            'menu_id': '20001',/*20024,20023,20025,20017*/
            ReqLinkType: '2'
        };
        $.getData({
            oSendData: oSendData,
            copyIsArray: false,
            isload: false,
            fnSuccess: function (data) {
                var aGrid = data.GRID0;
                var sHtml = '';
                if (aGrid) {
                    for (var i = 0; i < aGrid.length; i++) {
                        var _result = aGrid[i].split('|');
                        var obj = {};
                        obj.id = _result[data['IDINDEX']];//id
                        obj.ctime = _result[data['DATESINDEX']];//时间，日期
                        obj.imgUrl = _result[data['PICURLINDEX']];//图片
                        obj.source = _result[data['MEDIAINDEX']];//来源
                        obj.title = _result[data['INFOTITLEINDEX']];//标题

                        sHtml += loadDOM_TT_Old(obj);
                    }
                }

                if(aGrid.length >=20){
                    oVal.ywNextPage = true;
                }else{
                    oVal.ywNextPage = false;
                }

                $('.yaowen-list-other').append(sHtml);
                pageUrlOld();
                oVal.loadYWFlag = true;
            },
            oConfig:function(){

            }
        });
    }

    $(".page-wrapper").off("scroll").scroll(function(){
        //控制首页顶部显示，与客户端交互
        reqrolloffset();

        var scrollTop = $(".page-wrapper").scrollTop();
        var headerHeight = $(".header").height();
        var scrollHeight = $(".more-page").height() + headerHeight;//总高度
        var screenHeight = $("body").height();//屏幕高度
        // console.log("推荐页--",scrollHeight,(scrollTop + screenHeight*2));
        var appHeight = $(".app-header").height();
        if (commonFunction.compareVersion(oVal.currVersion, oVal.limitedVersion)) {
            appHeight = 0;
        }
        if(scrollTop >= (headerHeight - appHeight)){
            $(".nav-group").addClass("nav-group-fixed");
            if(appHeight != "0"){
                $(".nav-group").css("top",appHeight + "px")
                $('.title-bar').css({'display':'block','position': 'fixed','height':appHeight + "px",'width':'100%',"top":"0px",'z-index':'2'})
            }
        }else{
            $(".nav-group").removeClass("nav-group-fixed");
            if(appHeight != "0"){
                $(".nav-group").css("top","inherit")
                $('.title-bar').css({'display':'none','position': 'relative','height':"0px"})
            }
        }
        if(scrollTop + screenHeight*2 >= scrollHeight){
            if(oVal.loadYWFlag && oVal.ywNextPage){
                // console.log("加载数据");
                oVal.loadYWFlag = false;
                oVal.ywPageNum++;
                // console.log("oVal.configData.THS_MZ_KEY",oVal.configData.THS_MZ_KEY);
                /*if(oVal.configData.THS_MZ_KEY || oVal.configData.THS_MZ_KEY == "0"){
                    //旧版资讯推荐
                    getOldYaoWenOtherInfo();
                }else{
                    getYaoWenOtherInfo()
                }*/
                getYaoWenOtherInfo()
            }
        }
    })
</script>
</html>